home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4346 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: mail2news.demon.co.uk!hpl3sn03.cern.ch
  2. From: Dan Pop <danpop@mail.cern.ch>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Unbuffered character input...
  5. Date: Sat, 3 Feb 1996 22:21:29 +0100
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <9602032121.AA00122@dxmint.cern.ch>
  8. References: <Pine.SGI.3.91.960129190205.27936A-100000@tahiti.cs.unm.edu> <4elf0t$5vd@ixnews2.ix.netcom.com> <4ep3a1$bee@hacgate2.hac.com> <4eu2dt$pm2@elaine18.Stanford.EDU>
  9. X-NNTP-Posting-Host: hpl3sn03.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11. X-Mail2News-Path: dxmint.cern.ch!hpl3sn03.cern.ch
  12.  
  13. reckdahl@leland.Stanford.EDU (Keith Reckdahl) writes:
  14.  
  15. >I understand that it is hard to make I/O code portable, but 
  16. >is it truly *impossible* for C to have a portable unbuffered 
  17. >input function? 
  18.  
  19. Yes.
  20.  
  21. >Currently C has functions for many other 
  22. >hard-to-port capabilities such as system calls and process 
  23. >spawning.  
  24.  
  25. Nope.  C doesn't have any such functions.
  26.  
  27. >Wouldn't it possible to define an ANSI-standard unbuffered 
  28. >input function and then let the compiler people deal with 
  29. >the individual system details?
  30.  
  31. No.  The compiler people can't fix the problems related to terminals and
  32. operating systems that don't allow unbuffered terminal I/O.
  33.  
  34. >This makes more sense than forcing each individual 
  35. >programmer to re-invent the wheel by writing their own 
  36. >portable unbuffered input function.
  37.  
  38. On systems where unbuffered terminal I/O is possible, the vendors provide
  39. functions for unbuffered terminal I/O, there is no need for the programmer
  40. to reinvent anything (all s/he has to do is RTFM).
  41.  
  42. Having said this, I must add that functions like getch and kbhit could
  43. actually be added to the standard C library, in the same way as the time()
  44. function call was added: if the system/implementation cannot meaningfully
  45. support the function, it returns a special value.  Of course, programs
  46. blindly relying on such functions won't be more portable than they are
  47. today, even if they would compile and link without any problems.
  48.  
  49. Dan
  50. -- 
  51. Dan Pop
  52. CERN, CN Division
  53. Email: danpop@mail.cern.ch 
  54. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  55.